package com.ays.controller;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import com.atm.thirdplt.common.core.domain.AjaxResult;
import com.ays.service.HisBackService;
import com.ays.service.HisRequestHandleService;
import com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author Administrator
 * @date 2024/6/19
 * @desc 回写HIS
 */
@RestController
@RequestMapping("oper")
@Slf4j
public class HisBackController {

    @Autowired
    private ApplicationContext context;

    @Autowired
    private HisBackService hisBackService;

    @Autowired
    private HisRequestHandleService hisRequestHandleService;

    @RequestMapping("addOperEcho")
    public AjaxResult addOperEcho(@RequestBody List<Map<String,String>> list){
//        hisBackService.addOperEcho(list);
        log.info("手术状态更新:{}",list);
        new Thread(()->{
            JSONObject json = new JSONObject();
            json.put("data",list);
            HttpUtil.post("http://127.0.0.1:8092/ays-syn/oper/addOperEcho",json.toString());
        }).start();
        return AjaxResult.success();
    }

    @RequestMapping("logRetry")
    public String logRetry(@RequestBody Set<String> logIds, String flag) throws IOException {
        return hisRequestHandleService.logRetry(logIds,flag);
    }
}
